<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>docker | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="dockerDocker 是什么？Docker 是一个工具，它可以帮助开发者快速打包、分发和运行应用程序，确保程序在任何地方都能“在我电脑上能运行，也能在你电脑上运行”。 安装docker1234567891011121314151617181920212223242526272829303132# 更新本地包索引，确保能获取最新的软件包信息sudo apt-get update# 安装一些必要的">
<meta property="og:type" content="article">
<meta property="og:title" content="docker">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-docker/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="dockerDocker 是什么？Docker 是一个工具，它可以帮助开发者快速打包、分发和运行应用程序，确保程序在任何地方都能“在我电脑上能运行，也能在你电脑上运行”。 安装docker1234567891011121314151617181920212223242526272829303132# 更新本地包索引，确保能获取最新的软件包信息sudo apt-get update# 安装一些必要的">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-08-05T11:02:36.000Z">
<meta property="article:modified_time" content="2025-08-05T12:35:00.749Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="linux">
<meta property="article:tag" content="docker">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "docker",
  "url": "https://ckyfi9zero.github.io/2025/08/05/2025-08-05-docker/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-08-05T11:02:36.000Z",
  "dateModified": "2025-08-05T12:35:00.749Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-docker/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'docker',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">docker</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">docker</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-08-05T12:35:00.749Z" title="更新于 2025-08-05 20:35:00">2025-08-05</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/docker/">docker</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="docker"><a href="#docker" class="headerlink" title="docker"></a>docker</h1><p>Docker 是什么？<br>Docker 是一个工具，它可以帮助开发者快速打包、分发和运行应用程序，确保程序在任何地方都能“在我电脑上能运行，也能在你电脑上运行”。</p>
<h2 id="安装docker"><a href="#安装docker" class="headerlink" title="安装docker"></a>安装docker</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 更新本地包索引，确保能获取最新的软件包信息</span></span><br><span class="line"><span class="built_in">sudo</span> apt-get update</span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装一些必要的依赖工具，用于支持通过 HTTPS 使用软件源并管理 GPG 密钥</span></span><br><span class="line"><span class="comment"># - apt-transport-https: 允许 APT 通过 HTTPS 协议访问软件源</span></span><br><span class="line"><span class="comment"># - ca-certificates: 提供可信的 SSL 证书</span></span><br><span class="line"><span class="comment"># - curl: 用于下载文件（如 GPG 密钥）</span></span><br><span class="line"><span class="comment"># - software-properties-common: 提供添加软件源的工具（如 add-apt-repository）</span></span><br><span class="line"><span class="built_in">sudo</span> apt-get install apt-transport-https ca-certificates curl software-properties-common</span><br><span class="line"></span><br><span class="line"><span class="comment"># 从 Docker 官方下载 GPG 公钥，并将其转换为 APT 可识别的格式（dearmor），保存到指定路径</span></span><br><span class="line"><span class="comment"># 这一步是为了验证从 Docker 源下载的软件包的完整性与真实性</span></span><br><span class="line">curl -fsSL https://download.docker.com/linux/ubuntu/gpg | <span class="built_in">sudo</span> gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg</span><br><span class="line"></span><br><span class="line"><span class="comment"># 添加 Docker 的官方 APT 软件源到系统中</span></span><br><span class="line"><span class="comment"># - arch=amd64: 指定只适用于 x86_64 架构</span></span><br><span class="line"><span class="comment"># - signed-by: 指定用于验证此源的 GPG 密钥路径</span></span><br><span class="line"><span class="comment"># - $(lsb_release -cs): 自动获取当前 Ubuntu 发行版的代号（如 jammy、focal 等）</span></span><br><span class="line"><span class="comment"># - stable: 使用稳定版（stable）的 Docker 仓库</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">&quot;deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu <span class="subst">$(lsb_release -cs)</span> stable&quot;</span> | <span class="built_in">sudo</span> <span class="built_in">tee</span> /etc/apt/sources.list.d/docker.list &gt; /dev/null</span><br><span class="line"></span><br><span class="line"><span class="comment"># 再次更新包索引，使刚刚添加的 Docker 源生效</span></span><br><span class="line"><span class="built_in">sudo</span> apt-get update</span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装 Docker 的核心组件：</span></span><br><span class="line"><span class="comment"># - docker-ce: Docker Community Edition（社区版），即 Docker 引擎本身</span></span><br><span class="line"><span class="comment"># - docker-ce-cli: Docker 命令行工具</span></span><br><span class="line"><span class="comment"># - containerd.io: 容器运行时，负责管理容器的生命周期</span></span><br><span class="line"><span class="built_in">sudo</span> apt-get install docker-ce docker-ce-cli containerd.io</span><br><span class="line"></span><br><span class="line"><span class="comment"># 检查 Docker 是否安装成功，输出 Docker 版本信息</span></span><br><span class="line">docker --version</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="使用国内镜像"><a href="#使用国内镜像" class="headerlink" title="使用国内镜像"></a>使用国内镜像</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 编辑 Docker 配置文件</span></span><br><span class="line"><span class="built_in">sudo</span> gedit /etc/docker/daemon.json</span><br><span class="line"><span class="comment"># 添加或修改镜像源配置</span></span><br><span class="line">&#123;</span><br><span class="line">  <span class="string">&quot;registry-mirrors&quot;</span>: [</span><br><span class="line">    <span class="string">&quot;https://docker.m.daocloud.io&quot;</span>,</span><br><span class="line">    <span class="string">&quot;https://docker.1panel.live&quot;</span>,</span><br><span class="line">    <span class="string">&quot;https://hub.rat.dev&quot;</span></span><br><span class="line">  ]</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment"># 重启 Docker 服务使配置生效</span></span><br><span class="line"><span class="built_in">sudo</span> service docker restart</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="docker常用指令"><a href="#docker常用指令" class="headerlink" title="docker常用指令"></a>docker常用指令</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 拉取镜像(以nginx为例)</span></span><br><span class="line"><span class="built_in">sudo</span> docker pull docker.io/library/nginx:latest</span><br><span class="line"><span class="comment">#registry:仓库注册表地址（官方仓库可以省略：docker.io）</span></span><br><span class="line"><span class="comment">#namespace:命名空间（作者名）（官方镜像库可以省略：library）</span></span><br><span class="line"><span class="comment">#image:镜像名</span></span><br><span class="line"><span class="comment">#tag:标签（版本号：1.28.0）（可以省略：latest）</span></span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 运行容器(以nginx为例)</span></span><br><span class="line"><span class="built_in">sudo</span> docker run nginx</span><br><span class="line"><span class="comment"># 新开一个终端</span></span><br><span class="line"><span class="comment"># 查看正在运行的容器</span></span><br><span class="line"><span class="built_in">sudo</span> docker ps</span><br></pre></td></tr></table></figure>
<p>这样就是成功启动了<br><img src="https://ckyfi9zero.github.io/picx-images-hosting/20250805/image.pfnij44zc.webp" alt="image"></p>
<h3 id="每一列的解释："><a href="#每一列的解释：" class="headerlink" title="每一列的解释："></a><strong>每一列的解释：</strong></h3><ol>
<li><p><strong>CONTAINER ID</strong>  </p>
<ul>
<li><strong>含义</strong>：容器的唯一标识符（ID）。这是一个由 Docker 自动生成的、唯一的字符串，用于区分不同的容器。</li>
<li><strong>用途</strong>：你可以通过这个 ID 来管理容器（如停止、删除、进入等）。</li>
<li><strong>示例</strong>：<code>32d72b767bc5</code></li>
</ul>
</li>
<li><p><strong>IMAGE</strong>  </p>
<ul>
<li><strong>含义</strong>：创建该容器所使用的镜像名称。镜像是容器的模板，容器是镜像的实例化版本。</li>
<li><strong>用途</strong>：帮助你了解容器基于哪个镜像运行。</li>
<li><strong>示例</strong>：<code>nginx</code> 表示该容器使用的是官方的 Nginx 镜像。</li>
</ul>
</li>
<li><p><strong>COMMAND</strong>  </p>
<ul>
<li><strong>含义</strong>：容器启动时执行的命令。这是在运行容器时指定的命令，通常是从镜像的默认入口点（<code>ENTRYPOINT</code> 或 <code>CMD</code>）继承而来。</li>
<li><strong>用途</strong>：帮助你了解容器内部运行的具体命令。</li>
<li><strong>示例</strong>：<code>&quot;/docker-entrypoint...&quot;</code> 表示容器启动时执行了一个入口脚本（通常是镜像自带的启动脚本）。</li>
</ul>
</li>
<li><p><strong>CREATED</strong>  </p>
<ul>
<li><strong>含义</strong>：容器的创建时间，表示该容器何时被启动。</li>
<li><strong>用途</strong>：帮助你了解容器的生命周期。</li>
<li><strong>示例</strong>：<code>2 minutes ago</code> 表示该容器是在 2 分钟前创建的。</li>
</ul>
</li>
<li><p><strong>STATUS</strong>  </p>
<ul>
<li><strong>含义</strong>：容器的当前状态，包括运行时间和其他相关信息。</li>
<li><strong>用途</strong>：帮助你快速判断容器是否正常运行。</li>
<li><strong>示例</strong>：<code>Up 2 minutes</code> 表示容器已经运行了 2 分钟，并且处于正常运行状态。</li>
</ul>
</li>
<li><p><strong>PORTS</strong>  </p>
<ul>
<li><strong>含义</strong>：容器端口的映射情况。显示容器内部端口与主机端口之间的映射关系。</li>
<li><strong>用途</strong>：帮助你了解如何访问容器的服务。</li>
<li><strong>示例</strong>：<code>80/tcp</code> 表示容器内部的 80 端口（Nginx 默认监听端口）被映射到了主机的某个端口（具体端口号未显示，可能是因为没有绑定到主机端口，或者使用了默认的随机端口）。</li>
</ul>
</li>
<li><p><strong>NAMES</strong>  </p>
<ul>
<li><strong>含义</strong>：容器的名称。Docker 会为每个容器分配一个唯一的名称（如果用户没有手动指定名称，Docker 会自动生成一个随机名称）。</li>
<li><strong>用途</strong>：方便管理和识别容器。</li>
<li><strong>示例</strong>：<code>charming_ramanujan</code> 是 Docker 自动生成的一个随机名称，通常由形容词和名人名字组成。</li>
</ul>
</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">sudo</span> docker run -d -p 80:80 -v /home/bbb/nginx/html:/usr/share/nginx/html nginx</span><br><span class="line"><span class="comment"># -d: 后台运行（不会阻塞终端使用）</span></span><br><span class="line"><span class="comment"># -p 80:80: 映射端口（主机端口:容器端口）</span></span><br></pre></td></tr></table></figure>
<p>此时在网页访问localhost:80就打开了容器内部署的nginx<br><img src="https://ckyfi9zero.github.io/picx-images-hosting/20250805/image.3rbjjri78s.webp" alt="image"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/08/05/2025-08-05-docker/">https://ckyfi9zero.github.io/2025/08/05/2025-08-05-docker/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/linux/">linux</a><a class="post-meta__tags" href="/tags/docker/">docker</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">使用docker搭建pytorch环境</div></div></div></a><a class="pagination-related  no-desc" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">运动对象分割与配准算法</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/04/25/2025-04-25-linux%E4%B8%8B%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91/" title="linux下的科学上网"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-04-25</div><div class="info-item-2">linux下的科学上网</div></div></div></a><a class="pagination-related no-desc" href="/2025/05/06/2025-05-06-Ubuntu-GRUB-%E4%BF%AE%E5%A4%8D%E6%8C%87%E5%8D%97/" title="Ubuntu GRUB 修复指南"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-05-06</div><div class="info-item-2">Ubuntu GRUB 修复指南</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/29/2025-07-29-linux%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2%E7%8E%AF%E5%A2%83/" title="linux搭建博客环境"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-29</div><div class="info-item-2">linux搭建博客环境</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-12</div><div class="info-item-2">使用docker搭建pytorch环境</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#docker"><span class="toc-number">1.</span> <span class="toc-text">docker</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85docker"><span class="toc-number">1.1.</span> <span class="toc-text">安装docker</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E5%9B%BD%E5%86%85%E9%95%9C%E5%83%8F"><span class="toc-number">1.2.</span> <span class="toc-text">使用国内镜像</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#docker%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4"><span class="toc-number">1.3.</span> <span class="toc-text">docker常用指令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AF%8F%E4%B8%80%E5%88%97%E7%9A%84%E8%A7%A3%E9%87%8A%EF%BC%9A"><span class="toc-number">1.3.1.</span> <span class="toc-text">每一列的解释：</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>